package com.example.service;

import com.example.dao.CourseDao;
import com.example.entity.Course;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @program: demo4
 * @description:
 * @author: ChengY
 * @create: 2024-04-26 23:10
 */
@Service
public class CourseServiceImpl implements CourseService{
    @Resource
    private CourseDao courseDao;
    @Override
    public Course insertCourse(Course course) {
        return courseDao.save(course);
    }

    @Override
    public void deleteCourse(Long id) {
        courseDao.deleteById(id);
    }

    @Override
    public Course updateCourse(Course course) {
        return courseDao.save(course);
    }

    @Override
    public List<Course> findAllCourse() {
        return courseDao.findAll();
    }

    @Override
    public Course findCourseById(Long id) {
        return courseDao.findById(id).orElse(null);
    }
}
